package cn.pkubangbang.demo.democontact.entity;

import java.util.List;
import java.util.Objects;
import java.util.Set;
import org.springframework.http.HttpMethod;

/**
 * @Author: zhangzhenbang@k2data.com.cn
 * @Date: 2018-08-24 15:41
 */
public class MenuOption {

    private HttpMethod method;
    private String url;
    private String description;
    private Set<Role> rolesRequired;
    private List<Parameter> params;

    public MenuOption() {
    }

    public MenuOption(HttpMethod method, String url, String description,
        Set<Role> rolesRequired,
        List<Parameter> params) {
        this.method = method;
        this.url = url;
        this.description = description;
        this.rolesRequired = rolesRequired;
        this.params = params;
    }

    public HttpMethod getMethod() {
        return method;
    }

    public void setMethod(HttpMethod method) {
        this.method = method;
    }

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public Set<Role> getRolesRequired() {
        return rolesRequired;
    }

    public void setRolesRequired(Set<Role> rolesRequired) {
        this.rolesRequired = rolesRequired;
    }

    public List<Parameter> getParams() {
        return params;
    }

    public void setParams(List<Parameter> params) {
        this.params = params;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        MenuOption that = (MenuOption) o;
        return getMethod() == that.getMethod() &&
            Objects.equals(getUrl(), that.getUrl());
    }

    @Override
    public int hashCode() {

        return Objects.hash(getMethod(), getUrl());
    }

    @Override
    public String toString() {
        final StringBuilder sb = new StringBuilder("MenuOption{");
        sb.append("method=").append(method);
        sb.append(", url='").append(url).append('\'');
        sb.append(", description='").append(description).append('\'');
        sb.append(", rolesRequired=").append(rolesRequired);
        sb.append(", params=").append(params);
        sb.append('}');
        return sb.toString();
    }
}
